package com.ccc3gc.mysystem.service.impl;

import com.ccc3gc.mysystem.bean.UserAddress;
import com.ccc3gc.mysystem.mapper.UserAddressMapper;
import com.ccc3gc.mysystem.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Autowired
    public UserAddressMapper userAddressMaapper;
    /**获取用户地址列表
     * @param userAddress
     * @return userAddresses
     */
    @Override
    public List<UserAddress> selectAddressByUserId(UserAddress userAddress) {
        List<UserAddress> userAddresses = userAddressMaapper.selectAddressByUserId(userAddress);
        return userAddresses;
    }

    /**
     * @param userAddress
     * @return
     */
    @Override
    public UserAddress selectDetAdd(UserAddress userAddress) {
        UserAddress address = userAddressMaapper.selectDetAdd(userAddress);
        return address;
    }

    /**新增用户地址
     * @param userAddress
     * @return rows
     */
    @Override
    public int insertUserAddress(UserAddress userAddress) {
        int rows = userAddressMaapper.insertUserAddress(userAddress);
        return rows;
    }

    /**修改地址信息
     * @param userAddress
     * @param addressId
     * @return rows
     */
    @Override
    public int updateUserAddress(UserAddress userAddress, int addressId) {
        int rows = userAddressMaapper.updateUserAddress(userAddress, addressId);
        return rows;
    }

    /**删除用户地址
     * @param userId
     * @param addressId
     * @return rows
     */
    @Override
    public int deleteUserAddressByUserId(int userId, int addressId) {
        int rows = userAddressMaapper.deleteUserAddressByUserId(userId, addressId);
        return rows;
    }
}
